﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogCat.Utility
{
    class Log
    {
        public enum Level:int
        {
            Info        = 1,
            Warning     = 2,
            Error       = 3
        }

        public static void i(string tag,string msg) 
        {
            print(format(Level.Info,tag,msg));
        }

        public static void w(string tag, string msg)
        {
            print(format(Level.Warning, tag, msg));
        }

        public static void e(string tag, string msg)
        {
            print(format(Level.Error, tag, msg));
        }

        public static string time()
        {
            return DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss-fffffff");
        }

        /// <summary>
        /// 格式化日志
        /// </summary>
        public static string format(Level level,string tag,string msg) 
        {
            return "time="+time()+"|level="+level.ToString()+"|tag="+tag+"|msg="+msg;
        }

        /// <summary>
        /// 输出日志
        /// </summary>
        private static void print(string log)
        {
            Console.Out.WriteLine(log);
        }
    }
}
